package file;

import file.config.MyConfigProperties;
import file.util.FileUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @author hh
 * @since 2024/12/14
 */
@Order(1)
@Component
public class StartTipsRunner implements ApplicationRunner {

    private static final Logger log = LoggerFactory.getLogger(StartTipsRunner.class);
    private final MyConfigProperties myConfigProperties;

    public StartTipsRunner(MyConfigProperties myConfigProperties) {
        this.myConfigProperties = myConfigProperties;
    }

    @Override
    public void run(ApplicationArguments args) {
        log.info("文件上传路径为：{}，（启动时加:-DfilePath=xxx 修改）", myConfigProperties.getFilePath() == null ? FileUtil.getDefaultPath() : myConfigProperties.getFilePath());
        log.info("是否启用登录：{}，（启动时加:-DenableLogin=true or false 修改）", myConfigProperties.isEnableLogin());
        log.info("是否启用上传文件加密：{}，（启动时加:-Dencrypt=true or false 修改）", myConfigProperties.isEncrypt());
        try {
            String host = InetAddress.getLocalHost().getHostAddress();
            log.info("首页地址：http://{}:8888/console", host);
        } catch (UnknownHostException e) {
            log.error("获取本机地址失败", e);
        }
    }

}

